package com.tavio.vaultboy.element;

import java.util.UUID;

import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.tavio.vaultboy.collision.BoundingBox;
import com.tavio.vaultboy.element.type.ElementType;
import com.tavio.vaultboy.scene.SceneManager;

public class Element {
	protected BoundingBox boundingBox;
	
	public float x;
	
	public float y;
	
	public float width;
	
	public float height;
	
	public float acceleration;
	
	public float accelerationModifier;
	
	public float velocityX;
	
	public float velocityY;
	
	public boolean jumping;
	
	public ElementType elementType;
	
	protected VertexBufferObjectManager vertexBufferObjectManager;
	
	private UUID id = UUID.randomUUID();
	
	public Element(ElementType elementType, float x, float y, float width, float height, float acceleration, 
			VertexBufferObjectManager vertexBufferObjectManager) {
		this.vertexBufferObjectManager = vertexBufferObjectManager;
		this.elementType = elementType;
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		this.boundingBox = new BoundingBox(this, true, vertexBufferObjectManager, SceneManager.getInstance().getScene());
		this.acceleration = acceleration;
		this.velocityX = 0;
		this.velocityY = 0;
		this.accelerationModifier = 1;
		this.jumping = false;
	}

	public BoundingBox getBoundingBox() {
		return boundingBox;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Element other = (Element) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

}
